/*
 * Order 对象
 * @Author: chiangbt@geoportal.cn 
 * @Date: 2019-05-07 12:56:05 
 * @Last Modified by: chiangbt@geoportal.cn
 * @Last Modified time: 2019-05-15 15:07:24
 */
const mongoose = require('mongoose');

const orderSchema = mongoose.Schema({
    _id: mongoose.Schema.Types.ObjectId,
    // order 与 product 有关联
    product: {
        type: mongoose.Schema.Types.ObjectId,
        ref: 'Product',
        required: true
    },
    quantity: {
        type: Number,
        default: 1
    }
}, {
    versionKey: false,
    timestamps: {
        createdAt: 'createdAt',
        updatedAt: 'updatedAt'
    }
});

module.exports = mongoose.model('Order', orderSchema);